/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: Nov 21, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.gmatrix.ui;

import edu.psu.geovista.app.gmatrix.JDfMatrix;
import edu.psu.geovista.app.gmatrix.event.MatrixIndicationEvent;
import edu.psu.geovista.app.gmatrix.event.MatrixIndicationListener;
import edu.psu.geovista.app.gmatrix.event.MatrixSelectionEvent;
import edu.psu.geovista.app.gmatrix.event.MatrixSelectionListener;
import edu.psu.geovista.app.gmatrix.toolkit.MatrixLoggerMgr;

import java.awt.*;
import java.util.logging.Logger;

public class DfMatrixUI implements MatrixIndicationListener, MatrixSelectionListener {
    private static final Logger logger= Logger.getLogger(DfMatrixUI.class.getName());
    protected JDfMatrix matrix; //todo make it interface

    //protected ActionMgr actionMgr;

    public DfMatrixUI(JDfMatrix matrix) {
        this.matrix = matrix;
        setup();
    }

    public void setup(){
         //this.actionMgr =new ActionMgr();
      }

    public void setupEnd (){
        System.out.println("");
        /*DfSelectionModel selectmodel = matrix.getSelectmodel();
        //register internal selection src.
        DfMatrixCanvas canvas = this.matrix.getCanvas();
        canvas.addMatrixIndicationChangeListener(this);
        canvas.addMatrixSelectionChangeListener(this);

        selectmodel.addMatrixSelectionChangeListener(canvas);*/


    }

    public void matrixIndicationChanged(MatrixIndicationEvent e) {
        Point indication = e.getIndication();
        MatrixLoggerMgr.fine(logger,"indicate:"+indication.toString());
        matrix.fireIndicationChanged(indication);
        //logger.fine("indicate:"+indication.toString() );

    }

    /**
     * from internal
     * @param e
     */
    public void matrixSelectionChanged(MatrixSelectionEvent e) {
        /*int selecttype = e.getSelecttype();
         Set<Point> selection=null;
        if(selecttype==MatrixSelectionEvent.SELECT_CELL ){
            selection = e.getSelection();
             matrix.select(selection);
        }
        else if (selecttype==MatrixSelectionEvent.SELECT_ROW){
            int[] selectrows = e.getSelectrows();
            matrix.selectRow(selectrows);
           
        }
        else if(selecttype==MatrixSelectionEvent.SELECT_COL){
            int[] selectcols = e.getSelectcols();
            //matrix.sel(selectcols);
             int[] cols = e.getSelectcols();
            selection = matrix.getCellsByColumns(cols);
        }




        //matrix.select(selection);
        matrix.repaint();//after update row/column need do repaint
        matrix.fireSelectionChanged(selection);*/

    }


}
